import IamAccountResponse from '@/core/account/generated/types/model/response/IamAccountResponse'
import IamAccountWithProfileResponse from '@/core/account/types/model/response/IamAccountWithProfileResponse'
import { items as iamAccountProfileList } from '../generated/account/iamAccountProfileMockServerApi'
import mockProdServerUtils from '../utils/mockUtils'
import { MockMethod } from 'vite-plugin-mock'
import accountApiConfig from '@/core/account/apiconfig/accountApiConfig'

export const content: IamAccountResponse[] = []
for (let i = 0; i < 10; i++) {
	content.push({
		id: i.toString(),
		iamAppId: i.toString(),
		passwordChangeRequired: Math.floor(Math.random() * 2) + 1 === 1,
		status: i,
		deleteFlag: '0',
		createTime: new Date().getTime().toString(),
		updateTime: new Date().getTime().toString(),
		rowVersion: 1,
	} as IamAccountResponse)
}

export const accountWithProfileList: IamAccountWithProfileResponse[] = []
for (let i = 0; i < 10; i++) {
	accountWithProfileList.push({
		account: content[i],
		profile: iamAccountProfileList[i],
	} as IamAccountWithProfileResponse)
}

const mockList = [
	//...serverApiMockUtils.getDefaultServerApi(accountAdminApiConfig.iamAccount, content),
	// 搜索加profile对象接口
	{
		url: accountApiConfig.admin.iamAccountProfileGetByCurrentAccount.mockUri,
		method: accountApiConfig.admin.iamAccountProfileGetByCurrentAccount.method,
		timeout: 50,
		response: ({ body }: any) => {
			return {
				data: {
					content: accountWithProfileList,
					totalElements: 171,
				},
				code: 0,
				message: '成功',
			}
		},
	},
] as MockMethod[]

mockProdServerUtils.addPriorityMockList(1, ...mockList)
